<template>
	<view>
		<view class="login">
			<view class="idcount">
				<view class="">仓ID：</view>
				<input type="text" />
			</view>
			<view class="psw">
				<view class="">密码：</view>
				<input type="text" />
			</view>
			<button>登录</button>
		</view>
	</view>
</template>

<script>
import getfeishuToken from '../../unit/getfeishuToken.js';
import getAllGood from'../../unit/getAllGood.js'
	
export default {
	data() {
		return {
			token:"",
				chan: {
						chanName: '赢飞云仓',
						chanID: 'CK001',
						chanToken: 'HvwhbmjzXaYQjxsgJlHcJBMvntb',
						chanTableID: 'tbla9LaW5IiNZb7D',
						chanWXuserID:"tblko6gZi0oHAkYl",
						chanImgTableID:"tblBR0mg2hcq3YXV"
					},
					user: {
						userName: "",
						wxid: uni.getStorageSync('wxid'),
						wxName: uni.getStorageSync('nickName'),
						telphone: '',
						avatarUrl: uni.getStorageSync('avatarUrl')
					},
					pagetoken:"",
					checklist:[]
			
			
			
			
			
		};
	},
async onLoad() {
 var token= await getfeishuToken()
	 this.token=token.data.app_access_token
	var filter={}
 getAllGood(this.token,filter,this.chan,this.pagetoken).then((res)=>{
 console.log(JSON.stringify(res))	 
	 
 }) .catch((e)=>{
	 
	 
 })
	 
	},
	methods: {
		async tosaleBigin() {
				
				var that = this;
			  	var filterdata = false;
				do {
					try {
						const alldata = await getAllGood(this.token,filterdata, this.chan, this.pagetoken);
						that.all = alldata;
						that.pagetoken = alldata.data.data.page_token;
						that.hasmore = alldata.data.data.has_more;
						let temparr = [];
						temparr = alldata.data.data.items;
						console.log(JSON.stringify(temparr))
						for (let item of temparr) {
							let tempobj = {
								pinyin: '',
								商品ID: '',
								销售单位条码: '',
								商品名称: '',
								是否排期: false,
								货主名称: '',
								record_id: ''
							};
							tempobj.record_id = item.record_id;
		
							if (item.fields.是否排期 == true) {
								that.count++;
							}
							if (item.fields.hasOwnProperty('是否排期')) {
								tempobj.是否排期 = item.fields.是否排期;
							}
							tempobj.pinyin = pinyin(item.fields.商品名称.value[0].text, { pattern: 'first', toneType: 'none' }).replace(/\s/g, ''); 
							if (item.fields.hasOwnProperty('商品ID')) {
								tempobj.商品ID = item.fields.商品ID[0].text;
							}
							if (item.fields.hasOwnProperty('商品名称')) {
								tempobj.商品名称 = item.fields.商品名称.value[0].text;
							}
							if (item.fields.hasOwnProperty('货主名称')) {
								tempobj.货主名称 = item.fields.货主名称.value[0];
							}
							if (item.fields.hasOwnProperty('销售单位条码')) {
								tempobj.销售单位条码 = item.fields.销售单位条码.value[0].text;
							}
						 that.checklist.push(tempobj);
						 
						}
						that.newlist=that.checklist
					}catch(e){console.log('获取数据？'+e)} 
				} while (that.hasmore);
		
		}
		
		
		
	}
};
</script>

<style></style>
